"""
演示Python的正则表达式-基础匹配
"""

import re

s1 = "python itheima python itheima"
s2 = "1python itheima python itheima"

# match从头匹配
result1 = re.match("python", s1)
print(result1)
print(result1.span())
print(result1.group())
print("----------------------------------------")

# 因为re.match是从头开始匹配，所以如果第一个字母都没办法匹配，后面的内容则不会进行匹配，所以这里返回None
result2 = re.match("python", s2)
print(result2)
print("----------------------------------------")

# search匹配，从左到右搜索，找到第一个完全匹配的则返回，后续不再继续搜索
result3 = re.search("python", s2)
print(result3)
print("----------------------------------------")

result4 = re.search("python2", s2)
print(result4)
print("----------------------------------------")

# findall匹配，从左到右搜索，找出所有匹配到的内容，以list格式返回
result5 = re.findall("python", s2)
print(result5)
print("----------------------------------------")
result6 = re.findall("python2", s2)
print(result6)
print("----------------------------------------")
